package com.landinfo.domain;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * 红外相机管理
 * Create by lzq
 * 2017-11-02
 */
@ApiModel(description = "红外相机管理 Create by lzq 2017-11-02")
@Entity
@Table(name = "photo_management")
public class PhotoType implements Serializable {

    private static final long serialVersionUID = 1L;

    @Transient
    private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");


    //    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
//    @SequenceGenerator(name = "sequenceGenerator")
    @Id
    @Column(name = "id", length = 36)
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid2")
    private String id;


    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    @Column(name = "创建时间")
    private Date createDateTime;

    /**
     * 文件编号
     */
    @ApiModelProperty(value = "文件编号")
    @Column(name = "文件编号")
    private String fileNo;

    /**
     * 排序
     */
    @ApiModelProperty(value = "原始文件编号")
    @Column(name = "原始文件编号")
    private String fileNoOld;

    /**
     * 文件格式
     */
    @ApiModelProperty(value = "文件格式")
    @Column(name = "文件格式")
    private String fileType;

    /**
     * 相机信息
     */
    @ApiModelProperty(value = "文件夹编号")
    @Column(name = "文件夹编号")
    private String folderNo;


    /**
     * 相机编号
     */
    @ApiModelProperty(value = "相机编号")
    @Column(name = "相机编号",length = 100)
    private String cameraNo;


    /**
     * 布设点位编号
     */
    @ApiModelProperty(value = "布设点位编号")
    @Column(name = "布设点位编号",length = 100)
    private String layoutPointNo;


    /**
     * 拍摄日期
     */
    @ApiModelProperty(value = "拍摄日期")
    @Column(name = "拍摄日期",length = 10)
    private String shootDate;


    /**
     * 拍摄时间
     */
    @ApiModelProperty(value = "拍摄时间")
    @Column(name = "拍摄时间",length = 10)
    private String shootTime;


    /**
     * 工作天数
     */
    @ApiModelProperty(value = "工作天数")
    @Column(name = "工作天数")
    private String workDay;


    /**
     * 对象类别
     */
    @ApiModelProperty(value = "对象类别")
    @Column(name = "对象类别",length = 50)
    private String objectType;

    /**
     * 对象类别
     */
    @ApiModelProperty(value = "物种名称")
    @Column(name = "物种名称",length = 100)
    private String speciesName;


    /**
     * 动物数量
     */
    @ApiModelProperty(value = "动物数量")
    @Column(name = "动物数量")
    private Integer animalNumber;


    /**
     * 性别
     */
    @ApiModelProperty(value = "性别")
    @Column(name = "性别",length = 6)
    private String sex;


    /**
     * 独立探测首张
     */
    @ApiModelProperty(value = "独立探测首张")
    @Column(name = "独立探测首张")
    private String independentProbeFirst;


    /**
     * 备注
     */
    @ApiModelProperty(value = "备注")
    @Column(name = "备注")
    private String remark;


    //    //@JoinColumns(value={@JoinColumn(name="pointNo",referencedColumnName="id", foreignKey =@ForeignKey(name="layoutPointNo") )})
////    @JoinColumn(name = "pointNo",referencedColumnName="layoutPointNo")
//    //@JoinTable(name = "layoutPointNo",joinColumns = {@JoinColumn(name = "pointno")})
//    @JoinColumns(value={@JoinColumn(name="位点编号",referencedColumnName="位点编号",foreignKey =@ForeignKey(name="布设点位编号"))})

    @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
    @JoinColumn(name="布设点位编号", insertable = false,updatable = false)
    private CameraInfo cameraInfo = new CameraInfo();


    @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
    @JoinColumns(value={@JoinColumn(name="文件夹名称",referencedColumnName="文件夹编号")})
    private Set<PhotoTypePath> photoTypePaths=new LinkedHashSet<>(0);


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Date getCreateDateTime() {
        if (sdf == null) {
            sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        }
        if (createDateTime == null) {
            if (shootDate != null) {
                shootDate = shootDate.replace("/", "-");
                String tempStr = shootDate + " " + shootTime;
                if (shootTime == null) {
                    tempStr = shootDate;
                }
                try {
                    createDateTime = sdf.parse(tempStr);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

        }
        return createDateTime;
    }

    public void setCreateDateTime(Date createDateTime) {
        this.createDateTime = createDateTime;
    }


    public String getFileNo() {
        return fileNo;
    }

    public void setFileNo(String fileNo) {
        this.fileNo = fileNo;
    }

    public String getFileNoOld() {
        return fileNoOld;
    }

    public void setFileNoOld(String fileNoOld) {
        this.fileNoOld = fileNoOld;
    }

    public String getFileType() {
        return fileType;
    }

    public void setFileType(String fileType) {
        this.fileType = fileType;
    }

    public String getFolderNo() {
        return folderNo;
    }

    public void setFolderNo(String folderNo) {
        this.folderNo = folderNo;
    }

    public String getCameraNo() {
        return cameraNo;
    }

    public void setCameraNo(String cameraNo) {
        this.cameraNo = cameraNo;
    }

    public String getLayoutPointNo() {
        return layoutPointNo;
    }

    public void setLayoutPointNo(String layoutPointNo) {
        this.layoutPointNo = layoutPointNo;
    }

    public String getWorkDay() {
        return workDay;
    }

    public void setWorkDay(String workDay) {
        this.workDay = workDay;
    }

    public String getObjectType() {
        return objectType;
    }

    public void setObjectType(String objectType) {
        this.objectType = objectType;
    }

    public String getSpeciesName() {
        return speciesName;
    }

    public void setSpeciesName(String speciesName) {
        this.speciesName = speciesName;
    }

    public Integer getAnimalNumber() {
        return animalNumber;
    }

    public void setAnimalNumber(Integer animalNumber) {
        this.animalNumber = animalNumber;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getIndependentProbeFirst() {
        return independentProbeFirst;
    }

    public void setIndependentProbeFirst(String independentProbeFirst) {
        this.independentProbeFirst = independentProbeFirst;
    }


    public String getShootDate() {
        return shootDate;
    }

    public void setShootDate(String shootDate) {
        this.shootDate = shootDate;
    }

    public String getShootTime() {
        return shootTime;
    }

    public void setShootTime(String shootTime) {
        this.shootTime = shootTime;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }


    public CameraInfo getCameraInfo() {
        return cameraInfo;
    }

    public void setCameraInfo(CameraInfo cameraInfo) {
        this.cameraInfo = cameraInfo;
    }


    public Set<PhotoTypePath> getPhotoTypePaths() {
        return photoTypePaths;
    }

    public void setPhotoTypePaths(Set<PhotoTypePath> photoTypePaths) {
        this.photoTypePaths = photoTypePaths;
    }
}
